package robocup.component.coach;

import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;

import robocup.component.PConf;
import robocup.component.SConf;
import robocup.component.ControllerNumbers.PLAY_MODE;
import robocup.component.PConf.COMPARE_TYPE;
import robocup.component.actions.Action;
import robocup.component.actions.ChangePlayerTypeAction;
import robocup.component.infotypes.AuralInfo;
import robocup.component.infotypes.CoachPlayerSayInfo;
import robocup.component.infotypes.CoachVisualInfo;
import robocup.component.infotypes.PlayModeInfo;
import robocup.component.infotypes.PlayerSayInfo;
import robocup.component.infotypes.PlayerTypesInfo;
import robocup.component.infotypes.RefereeInfo;
import robocup.component.infotypes.SenseBodyInfo;
import robocup.component.infotypes.VisualInfo;
import robocup.component.speechacts.MessageFactory;
import robocup.component.speechacts.MessageFactory.MESSAGES;

/**
 * PlayerTypeAnalyzer analyzes the PConfs and ranks them for certain criteria.
 * Here you also can define the rule, when changing PlayerTypes during game
 * 
 * @author phil
 */
public class PlayerTypeAnalyzer implements CoachInfoReceiver {

	/**
	 * 
	 */
	private static final int MAX_TYPES = 1;

	// CoachWorld
	private CoachWorld cwm;

	// OLCoachTactic
	private OLCoachTactic olct;

	// Number of PConfs given by Server
	private final int pcSize = 18;

	// Number of our Players on field
	private int plSize;

	// PConfs given by Server
	private PConf[] allPConf;

	// Counts the PConfs, which are actually playing
	private int ptypeIsAv[];

	// contains the PConfs, by playerNumber - 1
	private PConf[] playingTypes;

	// Ranked Values from PConf
	// KM: Kickable Margin
	// DP: Dash Power Rate
	// St: Extra Stamina
	private int ranked_KM[];

	private int ranked_DP[];

	private int ranked_IM[];

	private int ranked_St[];

	private int ranked_Fast[];

	private int ranked_KM_IM[];

	private int ranked_KM_St[];

	private int ranked_DP_St[];

	private int ranked_2DP_1St[];

	private int ranked_1DP_2St[];

	private int ranked_KM_DP_St[];

	private final boolean[] alreadyChanged = new boolean[11];

	private boolean DEBUG_LEVEL_1 = true;

	private boolean DEBUG_LEVEL_2 = false;

	// this value gives the amount of time before halftime
	// in which changes are possible!
	private final double changeBeforeHalftime = 500;

	// Number of change Actions
	private int changeAction = 0;

	/**
	 * @param OLCoachTactic
	 */
	public PlayerTypeAnalyzer(final OLCoachTactic ol) {

		this.olct = ol;

		this.cwm = ol.getCwm();

		this.plSize = this.cwm.getTeammatesCount();

		this.allPConf = new PConf[this.pcSize];

		this.ptypeIsAv = new int[this.pcSize];
		this.playingTypes = new PConf[this.plSize];

		this.ranked_KM = new int[this.pcSize];
		this.ranked_DP = new int[this.pcSize];
		this.ranked_IM = new int[this.pcSize];
		this.ranked_St = new int[this.pcSize];
		this.ranked_Fast = new int[this.pcSize];
		this.ranked_KM_IM = new int[this.pcSize];
		this.ranked_KM_St = new int[this.pcSize];
		this.ranked_DP_St = new int[this.pcSize];
		this.ranked_2DP_1St = new int[this.pcSize];
		this.ranked_1DP_2St = new int[this.pcSize];
		this.ranked_KM_DP_St = new int[this.pcSize];
		Arrays.fill(this.alreadyChanged, false);
	}

	/**
	 * Called by Perception at the arrival of an AuralInfo.
	 * 
	 * @param Info
	 */
	public void update(final AuralInfo info) {

		if (info.toString().startsWith("PlayerMessage:")) {
			final CoachPlayerSayInfo cpsiInfo = ((CoachPlayerSayInfo) info);
			this.update(cpsiInfo);
		}
	}

	/**
	 * Called by Perception at the arrival of Player Types.
	 * 
	 * @param Info
	 */
	public void update(final PlayerTypesInfo info) {

		// all playertypes available
		if (info.playerTypesFull()) {
			this.allPConf = info.getPlayerTypes();
			this.playingTypes = this.analyze(this.allPConf);

			// map Players with playingTypes
			// do not use player 1
			for (int i = 1; i < this.playingTypes.length; i++) {
				try{
					final int id = this.playingTypes[i].getId();
					final Action a = new ChangePlayerTypeAction(i + 1, id);
					this.olct.sendDirect(a.toString());
				} catch(Exception e){
					e.printStackTrace();
				}
			}
		}
	}

	/**
	 * Called by Perception at the arrival of a VisualInfo.
	 * 
	 * @param Info
	 */
	public void update(final CoachVisualInfo info) {

	}

	public void update(final CoachPlayerSayInfo cpsi) {

		final MessageFactory mf = this.cwm.getMessageFactory();
		mf.generateMessages(cpsi.getMessage(), this.cwm.getServerCycle());
		final LinkedList<MESSAGES> types = mf.getMessageTypes();

		for (int i = 0; i < types.size(); i++) {
			final MESSAGES m = types.get(i);

			switch (m) {

			case RECOVERY:
				mf.decodeMessageNumber(i);
				if (mf.getRecovery() < 0.7
						&& !this.alreadyChanged[mf.getNumber() - 1]) {
					this.changePlayerType(mf.getNumber(), this.playingTypes[mf
							.getNumber() - 1].getId());
				}

				break;
			}
		}
	}

	/**
	 * Changes Playertype
	 * 
	 * Checks if possible for changing player action by certain criteria change
	 * only when Play Mode is not Play_on, changeaction is below 3 times,
	 * changeaction did not happen this play mode changeaction only in the
	 * second halftime
	 * 
	 * @param int
	 *            Playernumber of changing action
	 * @param int
	 *            The new Playertype given to player
	 * 
	 */
	public void changePlayerType(final int number, final int type) {

		if ((this.cwm.getPlayMode() != PLAY_MODE.PLAY_ON)
				&& (this.changeAction < 3)
				&& ((this.cwm.getVisualCycle() > (SConf.getInstance().HALF_TIME * 10)))
				|| (this.cwm.getVisualCycle() + this.changeBeforeHalftime < (SConf
						.getInstance().HALF_TIME * 10))) {
			final Action a = new ChangePlayerTypeAction(number, type);
			this.olct.sendDirect(a.toString());
			this.changeAction++;
			this.alreadyChanged[number - 1] = true;
			System.out.println(this.cwm.getVisualCycle() + " Changed Player "
					+ number + " to type: " + type);
		}

	}

	/**
	 * The PConf analyzer
	 * 
	 * @param PConfs
	 *            given by server (17 by default)
	 * @return PConf after analyzing it (11, each Player gets one)
	 */
	public PConf[] analyze(final PConf[] all) {

		// tell my world model about the available player types
		this.cwm.setPlayerTypes(all);

		final LinkedList<PConf> pConfs = new LinkedList<PConf>();
		for (final PConf pC : all) {
//			if (pC.getId() != 0) {
				pConfs.add(pC);
				pC.setCompareType(COMPARE_TYPE.SPEED);
//			}
		}
		// REMOVE THE SLOWEST PCONFS
		Collections.sort(pConfs);
		while (pConfs.size() > 14)
			pConfs.removeLast();

		// sorting PConf-Array by Kickable Margin
		for (final PConf pC : pConfs) {
			pC.setCompareType(COMPARE_TYPE.KICKABLE_DISTANCE);
		}
		Collections.sort(pConfs);
		for (int i = 0; i < pConfs.size(); i++) {
			this.ranked_KM[i] = pConfs.get(i).getId();
		}

		// sorting PConf-Array by Dash Power Rate
		for (final PConf pC : pConfs) {
			pC.setCompareType(COMPARE_TYPE.DASH_POWER);
		}
		Collections.sort(pConfs);
		for (int i = 0; i < pConfs.size(); i++) {
			this.ranked_DP[i] = pConfs.get(i).getId();
		}

		// sorting PConf-Array by Max Speed (decay and accel)
		for (final PConf pC : pConfs) {
			pC.setCompareType(COMPARE_TYPE.SPEED);
		}
		Collections.sort(pConfs);
		for (int i = 0; i < pConfs.size(); i++) {
			this.ranked_Fast[i] = pConfs.get(i).getId();
		}

		// sorting PConf-Array by INERTIA_MOMENT
		for (final PConf pC : pConfs) {
			pC.setCompareType(COMPARE_TYPE.INERTIA);
		}
		Collections.sort(pConfs);
		for (int i = 0; i < pConfs.size(); i++) {
			this.ranked_IM[i] = pConfs.get(i).getId();
		}

		// sorting PConf-Array by Extra Stamina
		for (final PConf pC : pConfs) {
			pC.setCompareType(COMPARE_TYPE.STAMINA);
		}
		Collections.sort(pConfs);
		for (int i = 0; i < pConfs.size(); i++) {
			this.ranked_St[i] = pConfs.get(i).getId();
		}

		// value weighting Kickable Margin - Stamina
		for (final PConf pC : pConfs) {
			pC.setCompareType(COMPARE_TYPE.STAMINA_AND_KICKABLE);
		}
		Collections.sort(pConfs);
		for (int i = 0; i < pConfs.size(); i++) {
			this.ranked_KM_St[i] = pConfs.get(i).getId();
		}

		// value weighting one-to-one Kickable Margin - Dash Power Rate -
		// Stamina
		for (final PConf pC : pConfs) {
			pC.setCompareType(COMPARE_TYPE.KICKABLE_AND_DASH_POWER_AND_STAMINA);
		}
		Collections.sort(pConfs);
		for (int i = 0; i < pConfs.size(); i++) {
			this.ranked_KM_DP_St[i] = pConfs.get(i).getId();
		}
		//
		// // value weighting Dash Power - Stamina
		for (final PConf pC : pConfs) {
			pC.setCompareType(COMPARE_TYPE.DASH_POWER_AND_STAMINA);
		}
		Collections.sort(pConfs);
		for (int i = 0; i < pConfs.size(); i++) {
			this.ranked_DP_St[i] = pConfs.get(i).getId();
		}
		//
		// // value weighting Kickable Margin - Stamina
		for (final PConf pC : pConfs) {
			pC.setCompareType(COMPARE_TYPE.KICKABLE_AND_INERTIA);
		}
		Collections.sort(pConfs);
		for (int i = 0; i < pConfs.size(); i++) {
			this.ranked_KM_IM[i] = pConfs.get(i).getId();
		}
		//    
		// // value weighting 1:2 Dash Power - Stamina
		for (final PConf pC : pConfs) {
			pC.setCompareType(COMPARE_TYPE.DASH_POWER_AND_DOUBLE_STAMINA);
		}
		Collections.sort(pConfs);
		for (int i = 0; i < pConfs.size(); i++) {
			this.ranked_1DP_2St[i] = pConfs.get(i).getId();
		}
		//    
		// // value weighting 2:1 Dash Power - Stamina
		for (final PConf pC : pConfs) {
			pC.setCompareType(COMPARE_TYPE.DOUBLE_DASH_POWER_AND_STAMINA);
		}
		Collections.sort(pConfs);
		for (int i = 0; i < pConfs.size(); i++) {
			this.ranked_2DP_1St[i] = pConfs.get(i).getId();
		}

		this.playingTypes = this.getPConfForPlayers(this);
		this.print();
		return this.playingTypes;
	}

	/**
	 * Refresh the ptypeIsAv after changing Player
	 */
	// public void tellPtypeIsAv() {
	// this.ptypeIsAv[this.oldPType]--;
	// this.ptypeIsAv[this.changeType]++;
	// }
	public String trim(String val){
		if (val.length()>7) return val.substring(0,7);
		return val;
	}
	
	/**
	 * Print the ranking values
	 */
	public void print() {

		if (!this.DEBUG_LEVEL_1) {
			return;
		}
		// Print Values of different Heterogenous Types
		StringBuffer buf = new StringBuffer();
		buf
				.append("\n I   Decay\tKickM\tIner\tExStam\tStamInc\tKRand\tAcMax\tSpdMx\tDashPower\tAssigned\n");
		for (int i = 0; i < this.allPConf.length; i++) {
			buf.append(" " + this.allPConf[i].getId() + "   ");
			buf.append(trim(""+this.allPConf[i].PLAYER_DECAY));
			buf.append("\t");
			buf.append(trim(""+this.allPConf[i].KICKABLE_MARGIN));
			buf.append("\t");
			buf.append(trim(""+this.allPConf[i].INERTIA_MOMENT));
			buf.append("\t");
			buf.append(trim(""+this.allPConf[i].EXTRA_STAMINA));
			buf.append("\t");
			buf.append(trim(""+this.allPConf[i].STAMINA_INC_MAX));
			buf.append("\t");
			buf.append(trim(""+this.allPConf[i].KICK_RAND));
			buf.append("\t");
			buf.append(trim(""+this.allPConf[i].PLAYER_ACCEL_MAX));
			buf.append("\t");
			buf
					.append(trim(""+Math
							.floor(this.allPConf[i].getEffectiveMaxSpeed() * 1000) / 1000.0));
			buf.append("\t");
			buf.append(trim(""+this.allPConf[i].DASH_POWER_RATE + "    "));
			buf.append("\t");

			for (int j = 0; j < this.playingTypes.length; j++) {
				try{
				if (this.playingTypes[j].getId() == this.allPConf[i].getId()) {
					buf.append((j + 1) + " ");
				}
				}catch(Exception e){
					
				}
			}
			buf.append('\n');

		}
		System.out.println(buf.toString());

		if (!this.DEBUG_LEVEL_2) {
			return;
		}
		// Print Values for research
		buf = new StringBuffer();
		buf.append("\n Ranking Type           PConf Position\n");
		buf.append(" ______________________  0 1 2 3 4 5 6\n\n");
		buf.append(" Ranked_KM: \t\t");
		for (final int i : this.ranked_KM) {
			buf.append(" " + i);
		}
		buf.append(" \n");

		buf.append(" Ranked_DP: \t\t");
		for (final int i : this.ranked_DP) {
			buf.append(" " + i);
		}
		buf.append(" \n");

		buf.append(" Ranked_IM: \t\t");
		for (final int i : this.ranked_IM) {
			buf.append(" " + i);
		}
		buf.append(" \n");

		buf.append(" Ranked_St: \t\t");
		for (final int i : this.ranked_St) {
			buf.append(" " + i);
		}
		buf.append(" \n");

		buf.append(" Ranked_KM_IM: \t\t");
		for (final int i : this.ranked_KM_IM) {
			buf.append(" " + i);
		}
		buf.append(" \n");

		buf.append(" Ranked_KM_St: \t\t");
		for (final int i : this.ranked_KM_St) {
			buf.append(" " + i);
		}
		buf.append(" \n");

		buf.append(" Ranked_DP_St: \t\t");
		for (final int i : this.ranked_DP_St) {
			buf.append(" " + i);
		}
		buf.append(" \n");

		buf.append(" Ranked_2DP_1St: \t");
		for (final int i : this.ranked_2DP_1St) {
			buf.append(" " + i);
		}
		buf.append(" \n");

		buf.append(" Ranked_1DP_2St: \t");
		for (final int i : this.ranked_1DP_2St) {
			buf.append(" " + i);
		}
		buf.append(" \n");

		buf.append(" Ranked_KM_DP_St: \t");
		for (final int i : this.ranked_KM_DP_St) {
			buf.append(" " + i);
		}
		buf.append(" \n");

		buf.append(" Ranked_FAST \t\t");
		for (final int i : this.ranked_Fast) {
			buf.append(" " + i);
		}
		buf.append(" \n");

		buf.append(" Players in Action: \t");
		for (final int i : this.ptypeIsAv) {
			buf.append(" " + i);
		}
		buf.append(" \n _________________powered by DAINAMITE\n\n");
		System.out.println(buf.toString());

	}

	public int[] getPtypeIsAv() {

		return this.ptypeIsAv;
	}

	public void setPtypeIsAv(final int[] ptypeIsAv) {

		this.ptypeIsAv = ptypeIsAv;
	}

	public int[] getRanked_KM() {

		return this.ranked_KM;
	}

	public int[] getRanked_DP() {

		return this.ranked_DP;
	}

	public int[] getRanked_2DP_1St() {

		return this.ranked_2DP_1St;
	}

	public int[] getRanked_1DP_2St() {

		return this.ranked_1DP_2St;
	}

	public int[] getRanked_IM() {

		return this.ranked_IM;
	}

	public int[] getRanked_DP_St() {

		return this.ranked_DP_St;
	}

	public int[] getRanked_KM_DP_St() {

		return this.ranked_KM_DP_St;
	}

	public int[] getRanked_KM_St() {

		return this.ranked_KM_St;
	}

	public int[] getRanked_KM_IM() {

		return this.ranked_KM_IM;
	}

	public int[] getRanked_St() {

		return this.ranked_St;
	}

	public int[] getRanked_Fast() {

		return this.ranked_Fast;
	}

	public int getPcSize() {

		return this.pcSize;
	}

	public PConf[] getAllPConf() {

		return this.allPConf;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see robocup.component.infotypes.InfoReceiver#update(robocup.component.infotypes.SenseBodyInfo)
	 */
	public void update(final SenseBodyInfo info) {

		// TODO Auto-generated method stub

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see robocup.component.infotypes.InfoReceiver#update(robocup.component.infotypes.VisualInfo)
	 */
	public void update(final VisualInfo info) {

		// TODO Auto-generated method stub

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see robocup.component.infotypes.InfoReceiver#update(robocup.component.infotypes.RefereeInfo)
	 */
	public void update(final RefereeInfo info) {

		// TODO Auto-generated method stub

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see robocup.component.infotypes.InfoReceiver#update(robocup.component.infotypes.PlayModeInfo)
	 */
	public void update(final PlayModeInfo info) {

		// TODO Auto-generated method stub

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see robocup.component.infotypes.InfoReceiver#update(robocup.component.infotypes.PlayerSayInfo)
	 */
	public void update(final PlayerSayInfo info) {

		// TODO Auto-generated method stub

	}

	/**
	 * This method decides which hetero-playertype will be associated with the
	 * player with number i
	 * 
	 * @param i -
	 *            the number of the player
	 * @param types -
	 *            a list containing all available types 3 times, initially.
	 *            Selected type will be removed!
	 * @return the PConf, which was selected!
	 */
	public PConf[] getPConfForPlayers(final PlayerTypeAnalyzer pta) {

		final PConf[] all = pta.getAllPConf();
		final PConf[] resultPConf = new PConf[11];

		final int pcSize = pta.getPcSize();
		final int ptypeIsAv[] = pta.getPtypeIsAv();

		// Ranked Values from PConf
		// KM: Kickable Margin
		// DP: Dash Power Rate
		// IM: Inertia Moment
		// St: Extra Stamina
		// final int ranked_KM[] = pta.getRanked_KM();
//		final int ranked_DP[] = pta.getRanked_DP();
		final int ranked_St[] = pta.getRanked_St();
		// final int ranked_Fast[] = pta.getRanked_Fast();
		// final int ranked_KM_IM[] = pta.getRanked_KM_IM();
		// final int ranked_KM_St[] = pta.getRanked_KM_St();
//		final int ranked_DP_St[] = pta.getRanked_DP_St();
		final int ranked_1DP_2St[] = pta.getRanked_1DP_2St();
//		final int ranked_2DP_1St[] = pta.getRanked_2DP_1St();
		final int ranked_KM_DP_St[] = pta.getRanked_KM_DP_St();

		// Player assignment

		// Set Goalie
		//resultPConf[0] = all[0].cloned();
		//ptypeIsAv[0]++;

//		resultPConf[2] = all[ranked_DP[0]].cloned();
//		resultPConf[3] = all[ranked_DP[1]].cloned();
//		resultPConf[1] = all[ranked_DP[2]].cloned();
//		resultPConf[4] = all[ranked_DP[3]].cloned();
//		resultPConf[9] = all[ranked_DP[4]].cloned();
//		resultPConf[8] = all[ranked_DP[5]].cloned();
//		resultPConf[10] = all[ranked_DP[6]].cloned();
//		resultPConf[5] = all[ranked_DP[7]].cloned();
//		resultPConf[6] = all[ranked_DP[8]].cloned();
//		resultPConf[7] = all[ranked_DP[9]].cloned();
//		if (true) return resultPConf;
		// Set Player 4
		for (int i = 0; i < pcSize; i++) {
			if (ptypeIsAv[ranked_1DP_2St[i]] < MAX_TYPES) {
				resultPConf[3] = all[ranked_1DP_2St[i]].cloned();
				ptypeIsAv[ranked_1DP_2St[i]]++;
				break;
			}
		}

		// Set Player 3
		for (int i = 0; i < pcSize; i++) {
			if (ptypeIsAv[ranked_1DP_2St[i]] < MAX_TYPES) {
				resultPConf[2] = all[ranked_1DP_2St[i]].cloned();
				ptypeIsAv[ranked_1DP_2St[i]]++;
				break;
			}
		}

		// Set Player 6
		for (int i = 0; i < pcSize; i++) {
			if (ptypeIsAv[ranked_St[i]] < MAX_TYPES) {
				resultPConf[5] = all[ranked_St[i]].cloned();
				ptypeIsAv[ranked_St[i]]++;
				break;
			}
		}

		// Set Player 2
		for (int i = 0; i < pcSize; i++) {
			if (ptypeIsAv[ranked_1DP_2St[i]] < MAX_TYPES) {
				resultPConf[1] = all[ranked_1DP_2St[i]].cloned();
				ptypeIsAv[ranked_1DP_2St[i]]++;
				break;
			}
		}

		// Set Player 8
		for (int i = 0; i < pcSize; i++) {
			if (ptypeIsAv[ranked_St[i]] < MAX_TYPES) {
				resultPConf[7] = all[ranked_St[i]].cloned();
				ptypeIsAv[ranked_St[i]]++;
				break;
			}
		}

		// Set Player 5
		for (int i = 0; i < pcSize; i++) {
			if (ptypeIsAv[ranked_1DP_2St[i]] < MAX_TYPES) {
				resultPConf[4] = all[ranked_1DP_2St[i]].cloned();
				ptypeIsAv[ranked_1DP_2St[i]]++;
				break;
			}
		}

		// Set Player 7
		for (int i = 0; i < pcSize; i++) {
			if (ptypeIsAv[ranked_St[i]] < MAX_TYPES) {
				resultPConf[6] = all[ranked_St[i]].cloned();
				ptypeIsAv[ranked_St[i]]++;
				break;
			}
		}

		// Set Player 11
		for (int i = 0; i < pcSize; i++) {
			if (ptypeIsAv[ranked_KM_DP_St[i]] < MAX_TYPES) {
				resultPConf[10] = all[ranked_KM_DP_St[i]].cloned();
				ptypeIsAv[ranked_KM_DP_St[i]]++;
				break;
			}
		}

		// Set Player 9
		for (int i = 0; i < pcSize; i++) {
			if (ptypeIsAv[ranked_KM_DP_St[i]] < MAX_TYPES) {
				resultPConf[8] = all[ranked_KM_DP_St[i]].cloned();
				ptypeIsAv[ranked_KM_DP_St[i]]++;
				break;
			}
		}

		// Set Player 10
		for (int i = 0; i < pcSize; i++) {
			if (ptypeIsAv[ranked_KM_DP_St[i]] < MAX_TYPES) {
				resultPConf[9] = all[ranked_KM_DP_St[i]].cloned();
				ptypeIsAv[ranked_KM_DP_St[i]]++;
				break;
			}
		}

		/*
		 * // Set Player 10 for (int i = 0; i < pcSize; i++) { if
		 * (ptypeIsAv[ranked_DP[i]] < 3) { resultPConf[9] =
		 * all[ranked_DP[i]].cloned(); ptypeIsAv[ranked_DP[i]]++; break; } }
		 *  // Set Player 4 for (int i = 0; i < pcSize; i++) { if
		 * (ptypeIsAv[ranked_DP[i]] < 3) { resultPConf[3] =
		 * all[ranked_DP[i]].cloned(); ptypeIsAv[ranked_DP[i]]++; break; } }
		 *  // Set Player 7 for (int i = 0; i < pcSize; i++) { if
		 * (ptypeIsAv[ranked_KM_DP_St[i]] < 3) { resultPConf[6] =
		 * all[ranked_KM_DP_St[i]].cloned(); ptypeIsAv[ranked_KM_DP_St[i]]++;
		 * break; } }
		 *  // Set Player 9 for (int i = 0; i < pcSize; i++) { if
		 * (ptypeIsAv[ranked_DP_St[i]] < 3) { resultPConf[8] =
		 * all[ranked_DP_St[i]].cloned(); ptypeIsAv[ranked_DP_St[i]]++; break; } }
		 *  // Set Player 11 for (int i = 0; i < pcSize; i++) { if
		 * (ptypeIsAv[ranked_2DP_1St[i]] < 3) { resultPConf[10] =
		 * all[ranked_2DP_1St[i]].cloned(); ptypeIsAv[ranked_2DP_1St[i]]++;
		 * break; } }
		 *  // Set Player 3 for (int i = 0; i < pcSize; i++) { if
		 * (ptypeIsAv[ranked_DP[i]] < 3) { resultPConf[2] =
		 * all[ranked_DP[i]].cloned(); ptypeIsAv[ranked_DP[i]]++; break; } }
		 *  // Set Player 6 for (int i = 0; i < pcSize; i++) { if
		 * (ptypeIsAv[ranked_1DP_2St[i]] < 3) { resultPConf[5] =
		 * all[ranked_1DP_2St[i]].cloned(); ptypeIsAv[ranked_1DP_2St[i]]++;
		 * break; } }
		 *  // Set Player 8 for (int i = 0; i < pcSize; i++) { if
		 * (ptypeIsAv[ranked_1DP_2St[i]] < 3) { resultPConf[7] =
		 * all[ranked_1DP_2St[i]].cloned(); ptypeIsAv[ranked_1DP_2St[i]]++;
		 * break; } }
		 *  // Set Player 2 for (int i = 0; i < pcSize; i++) { if
		 * (ptypeIsAv[ranked_St[i]] < 3) { resultPConf[1] =
		 * all[ranked_St[i]].cloned(); ptypeIsAv[ranked_St[i]]++; break; } }
		 *  // Set Player 5 for (int i = 0; i < pcSize; i++) { if
		 * (ptypeIsAv[ranked_St[i]] < 3) { resultPConf[4] =
		 * all[ranked_St[i]].cloned(); ptypeIsAv[ranked_St[i]]++; break; } }
		 */

		pta.setPtypeIsAv(ptypeIsAv);
		return resultPConf;
	}

}

/**
 * $Log: PlayerTypeAnalyzer.java,v $ Revision 1.19 2006/07/31 14:24:42 endert
 * Removed loggings!
 * 
 * Revision 1.18 2006/07/11 21:39:57 endert renewed logging
 * 
 * Revision 1.17 2006/07/11 21:28:40 endert log player types
 * 
 * Revision 1.16 2006/06/27 11:56:33 endert Reset Debug_Level_1 to active
 * 
 * Revision 1.15 2006/06/27 11:01:54 phil changed debug level
 * 
 * Revision 1.14 2006/06/27 10:15:42 phil removed some comments
 * 
 * 
 */
